#!/bin/bash
cd ~/app-root/data/temp/xpi/push/
ls ~/app-root/repo/扩展/ |grep xpi >./ls.txt
if diff ls.txt backup.txt |sed -e '/---/,$d' -e 's#< ##' >./diff.txt; then
mv -f ls.txt backup.txt
if grep "AdblockEdge2-" diff.txt|grep -o "[0-9\.]\{2,\}" >./latest.txt; then
sed -i "s#[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}#`cat latest.txt`#" ~/app-root/data/xpi/rdf/AdblockEdge2.rdf
fi
if grep "adblockplus2-" diff.txt|grep -o "[0-9\.]\{2,\}" >./latest.txt; then
sed -i "s#[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}#`cat latest.txt`#" ~/app-root/data/xpi/rdf/AdblockPlus2.rdf
fi
if grep "acvaa-" diff.txt|grep -o "[0-9\.]\{2,\}" >./latest.txt; then
sed -i "s#[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}#`cat latest.txt`#" ~/app-root/data/xpi/rdf/acvaa.rdf
sed -i "s#[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}#`cat latest.txt`#" ~/app-root/data/xpi/rdf/acvaa2.rdf
fi
if grep "mynewtab-" diff.txt|grep -o "[0-9\.]\{2,\}" >./latest.txt; then
sed -i "s#[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}#`cat latest.txt`#" ~/app-root/data/xpi/rdf/mynewtab.rdf
fi
if grep "Pan2-" diff.txt|grep -o "[0-9\.]\{2,\}" >./latest.txt; then
sed -i "s#[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}#`cat latest.txt`#" ~/app-root/data/xpi/rdf/pan2.rdf
fi
#if grep "PuzzleBars2-" diff.txt|grep -o "[0-9\.]\{2,\}" >./latest.txt; then
#sed -i "s#[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}#`cat latest.txt`#" ~/app-root/data/xpi/rdf/puzzlebars2.rdf
#fi
if grep "Pan2ehh-" diff.txt|grep -o "[0-9\.]\{2,\}" >./latest.txt; then
sed -i "s#[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}#`cat latest.txt`#" ~/app-root/data/xpi/rdf/pan2ehh.rdf
fi
if grep "userChromeJSModify2-" diff.txt|grep -o "[0-9\.]\{2,\}" >./latest.txt; then
sed -i "s#[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{2\}#`cat latest.txt`#" ~/app-root/data/xpi/rdf/userChromeJSModify2.rdf
fi
fi
rm -f ls.txt diff.txt latest.txt
cd ~/app-root/runtime/repo/扩展/
rm -f $OPENSHIFT_DATA_DIR/xpi/*.xpi
cp -f *-signed.xpi $OPENSHIFT_DATA_DIR/xpi/
cd $OPENSHIFT_DATA_DIR/xpi/
git add --all
git commit -m "update"
git push -u origin master
